package weifei.mall.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.stereotype.Repository;


/**
 *
 * -- 商品图片表
 * CREATE TABLE goods_picture
 * (
 *     id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
 *     seller_id INT UNSIGNED NOT NULL,
 *     goods_id BIGINT UNSIGNED NOT NULL,
 *     `order` TINYINT UNSIGNED NOT NULL,
 *     content MEDIUMBLOB NOT NULL COMMENT "图片内容",
 *     PRIMARY KEY (id),
 *     FOREIGN KEY (seller_id) REFERENCES user(id),
 *     FOREIGN KEY (goods_id) REFERENCES goods(id)
 * );
 *
 * */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("goods_picture")
@Repository
public class GoodsPicture extends Model<GoodsPicture>
{

    @Getter
    public enum Column
    {
        ID("id"),
        SellerID("seller_id"),
        GoodsID("goods_id"),
        Order("`order`"),
        Content("content");

        final String name;
        Column(String name) { this.name = name; }
    }

    @TableId
    private Integer id;
    private Integer sellerId;
    private Integer goodsId;
    @TableField("`order`")
    private Integer order;
    private byte[] content;


    public GoodsPicture() {}
    public GoodsPicture(int id) { this.id = id; }
    public GoodsPicture(int sellerId, int goodsId, int order, byte[] content)
    {
        this.sellerId = sellerId;
        this.goodsId = goodsId;
        this.order = order;
        this.content = content;
    }
}

